<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="he">
        <input type="checkbox" name="" id="" class="qx"><button class="qxa">全选</button><button class="fx">反选</button>
        <p class="xian"></p>
        <div><input type="checkbox" name="" id="" class="xx">选项一</div>
        <div><input type="checkbox" name="" id="" class="xx">选项二</div>
        <div><input type="checkbox" name="" id="" class="xx">选项三</div>
        <div><input type="checkbox" name="" id="" class="xx">选项四</div>
        <div><input type="checkbox" name="" id="" class="xx">选项五</div>
        <div><input type="checkbox" name="" id="" class="xx">选项六</div>
        <div><input type="checkbox" name="" id="" class="xx">选项七</div>
        <div><input type="checkbox" name="" id="" class="xx">选项八</div>
        <div><input type="checkbox" name="" id="" class="xx">选项九</div>
        <div><input type="checkbox" name="" id="" class="xx">选项十</div>
    </div>
</body>

</html>
<style>
    .he {
        width: 150px;
        height: 500px;
        margin: 0 auto;
    }

    p {
        width: 80%;
        margin: 0 auto;
        height: 2px;
        background-color: black;
    }
</style>
<script>
    var qx = document.querySelector(".qx")
    var qxa = document.querySelector(".qxa")
    var fx = document.querySelector(".fx")
    var xx=document.querySelectorAll(".xx")
    qx.onclick=function(){
        for (let i = 0; i < xx.length; i++) {
            xx[i].type.checkbox=true
            qxa.type.checkbox=true
        }
    }
    for (let i = 0; i < xx.length; i++) {
       if (xx[i]==true) {
           qxa=true
       }
    }

</script>